﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Windows;
using System.Windows.Controls;


namespace PacketBuilder
{
    public partial class MainWindow
    {
        public static void TextBoxChanged(object sender, TextChangedEventArgs e)
        {
            var senderControl = sender as TextBox;
            if (null == senderControl.Tag)
            {
                return;
            }            
            optionsMap[(string)senderControl.Tag] = senderControl.Text;            
        }

        public static void CheckBoxStateChanged(object sender, RoutedEventArgs e)
        {
            var senderCheckBox = sender as CheckBox;
            if (null == senderCheckBox.Tag)
            {
                return;
            }
            if (null != senderCheckBox.IsChecked)
            {
                optionsMap[(string)senderCheckBox.Tag] = (bool)senderCheckBox.IsChecked ? "1" : "0";                
            }
        }

        public static void ComboBoxStateChanged(object sender, SelectionChangedEventArgs e)
        {
            var senderComboBox = sender as ComboBox;
            if (null == senderComboBox.Tag)
            {
                return;
            }
            if (null != senderComboBox.SelectedItem)
            {
                optionsMap[(string)senderComboBox.Tag] = (senderComboBox.SelectedIndex + 1).ToString();
            }
        }        
    }
}